import tornado.ioloop
import tornado.web

from config import logger

route_list = []


def make_app():
    return tornado.web.Application(route_list)


async def init():
    # 加路由
    from handlers.urls import url_list
    for url in url_list:
        if len(url) > 2:
            route_list.append((url[0], url[1]))
        else:
            route_list.append(url)


if __name__ == "__main__":
    # 当前的IOLOOP对象:一个事件循环对象
    loop = tornado.ioloop.IOLoop.current()
    loop.run_sync(init)
    app = make_app()
    app.listen(33333)
    logger.info("Server started on 33333")
    loop.start()
